-
-
Notifications
You must be signed in to change notification settings - Fork 3k
Support _value_
as a fallback for ellipsis Enum members
#19352
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support _value_
as a fallback for ellipsis Enum members
#19352
Conversation
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, a couple nitpicks.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
…19334-respect-enum-sunder-value
According to mypy_primer, this change doesn't affect type check results on a corpus of open source code. ✅ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, looks good, except for a nit about cyclic import dependencies. This is good to merge as is, since the issue is pretty minor, but it would be nice you can fix it in a follow-up PR.
@@ -17,10 +17,12 @@ | |||
from typing import TypeVar, cast | |||
|
|||
import mypy.plugin # To avoid circular imports. | |||
from mypy.nodes import TypeInfo | |||
from mypy.checker import TypeChecker |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's a bit unfortunate that we have another circular import dependency. What about adding adding a helper method for checking whether we are type checking a stub file to the checker api? (It's okay to do this in a follow-up PR.)
Fixes #19334.
This does not affect enums with explicit values different from ellipsis and is limited to enums defined in stub files.